package cn.pku.ss.fa.ui.component;

import javax.naming.InitialContext;
import org.zkoss.zul.Window;
import cn.pku.ss.fa.bean.PersonalBean;
import cn.pku.ss.fa.sessionbean.UserManagerLocal;

public class PersonalComponent extends Window{
	
	public PersonalBean getPersonalBean(int userId) {
		PersonalBean personalBean = null;// = this.getPersonalBean_test();
		try {
			InitialContext ctx = new InitialContext();
			UserManagerLocal userDao = (UserManagerLocal)ctx.lookup("FriendsAnywhere/UserManager/local");
			personalBean = userDao.findUserByUserId(userId);
		} catch(Exception e) {
			e.printStackTrace();
		}
		return personalBean;
	}

	public void updateStatus(int userId, String newStatus){
		try {
			InitialContext ctx = new InitialContext();
			UserManagerLocal userDao = (UserManagerLocal)ctx.lookup("FriendsAnywhere/UserManager/local");
			userDao.updateUserStatusByUserId( userId, newStatus );
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
//	private PersonalBean getPersonalBean_test() {
//		PersonalBean bean = new PersonalBean();
//		bean.setId(100);
//		bean.setUserName("sirx");
//		bean.setRealName("Bill Gates");
//		bean.setBirthDay("2008-12-12");
//		bean.setProvince("Jiangsu");
//		CityBean cityBean = new CityBean();
//		cityBean.setCityName("Nanjing");
//		bean.setCity(cityBean);
//		bean.setMsn("xx@xx.com");
//		bean.setQq("876543210");
//		bean.setPhoneNumber("12345678901");
//		bean.setSite("http://www.g.cn");
//		bean.setStatus("I'm your boss!!! many words many words many words many words many words ");
//		List<EducationExperience> list1 = new LinkedList<EducationExperience>();
//		EducationExperience educationExperience = new EducationExperience();
//		educationExperience.setStartDate("2008-1-1");
//		educationExperience.setEndDate("2008-12-1");
//		educationExperience.setSchool("Peking University");
//		educationExperience.setExperience("Doctor");
//		list1.add(educationExperience);
//		bean.setEducationExperiences(list1);
//		List<WorkExperience> list2 = new LinkedList<WorkExperience>();
//		WorkExperience workExperience = new WorkExperience();
//		workExperience.setCompany("IBM");
//		workExperience.setPosition("Project Manager");
//		workExperience.setDescription("I entered IBM in 1987-2-21, and was fired yesterday.");
//		list2.add(workExperience);
//		bean.setWorkExperiences(list2);
//		return bean;
//	}
}
